<template>
  <div class="SinglesPage" v-wechat-title="pageDate.title">
    <div class="header" v-if="pageDate.banner.length>0">
      <product-con-swiper
        :img-urls="imageList"
      ></product-con-swiper>
      <!-- <img :src="pageDate.banner[0].img+
                  '?x-oss-process=image/resize,limit_0,m_fill,w_375,h_200/quality,q_100'" alt="" /> -->
    </div>
    <!-- <div v-for="oneList in goodsList" :key="oneList.id" class="father">
      <div class="goodsList">
        <div class="dis">
          <img src="@assets/images/superSaleZJ/title.png" alt="" />
        </div> -->


        <div class="listDivSmall">
          <div class="goodsLists">
            <div
              class="good"
              v-for="oneGood in pageDate.product"
              :key="oneGood.id"
            >
              <img
                class="goodPic"
                @click="toDetail(oneGood.id)"
                v-lazy="
                  oneGood.image +
                  '?x-oss-process=image/resize,limit_0,m_fill,w_200,h_200/quality,q_100'
                "
                alt=""
                srcset=""
              />
              <div
                class="noGood"
                @click="toDetail(oneGood.id)"
                v-if="oneGood.stock == '0'"
              >
                <p class="wordAlert">补货中</p>
              </div>
              <div class="goodDetail" @click="toDetail(oneGood.id)">
                <p class="title">{{ oneGood.store_name }}</p>
                <div class="shareAndget">
                </div>
                <p class="price">
                  <span style="font-weight: bold">￥</span>
                  <span style="font-weight: bold" class="nowPrice">{{
                    oneGood.price
                  }}</span>
                  <span class="oldPrice">￥{{ oneGood.ot_price }}</span>
                </p>
              </div>
            </div>
          </div>
        </div>



        <!-- <div class="listDivBig" v-if="oneList.listDivBig.length > 0">
          <img
            @click="toDetail(img.id)"
            v-for="img in oneList.listDivBig"
            :key="img.id"
            v-lazy="img.url"
            alt=""
          />
        </div> -->
        <!-- <div class="lookmore" v-show="oneList.type == '2'">
                <p @click="toSalePage">更多特惠</p>
                <img @click="toSalePage" src="@assets/images/superSaleZJ/more.png" alt="" srcset="">
            </div> -->
      </div>
    <!-- </div> -->
  <!-- </div> -->
</template>
<script>
import Recommend from "@components/Recommend";
import cookie from "@utils/store/cookie";
// import debounce from "lodash.debounce";
import {superSaleMould} from "@/api/activeMould";
import share from "../../assets/js/common/share.js";
import shareMsg from "../../assets/js/common/shareConfig.js";
import ProductConSwiper from "@components/ProductConSwiper";
const CHECKED_IDS = "cart_checked";

export default {
  name: "SinglesPage",
  components: {
    Recommend,
    ProductConSwiper
  },
  props: {},
  data: function () {
    return {
      deg: "0",
      from1: "h5",
      actId:'',
      pageDate:{
          banner:[],
          product:[]
      },
      imageList:[]
    };
  },
  watch: {},
  mounted: function () {

    this.getData();
    if (this.$route.query.isToken) {
      this.$store.commit(
        "LOGIN",
        this.$route.query.isToken
        // dayjs(expires_time) - newTime
      );
      cookie.set("OID", this.$route.query.oId);
    }
    var shareUrl1 = window.location.href.split("?")[0];
    if (this.$route.query.from1 == "app") {
      shareMsg.shareConfig(
        "app",
        "0",
        "0",
        "湛江广播年货节",
        "听见广播",
        shareUrl1,
        "https://seefm.oss-cn-beijing.aliyuncs.com/image/icon.png",
        "",
        "1"
      );
    }
    share.share(
      shareUrl1,
      "湛江广播年货节",
      "听见广播",
      "https://seefm.oss-cn-beijing.aliyuncs.com/image/icon.png"
    );
    share.QQshare(
      shareUrl1,
      "湛江广播年货节",
      "听见广播",
      "https://seefm.oss-cn-beijing.aliyuncs.com/image/icon.png"
    );
  },
  created() {
    if (this.$route.query.from1) {
      this.from1 = this.$route.query.from1;
    }
    this.actId = this.$route.query.actId;
    cookie.set("from1", this.from1);
    this.changeDeg();
    if (this.from1 == "app") {
      this.getTitle();
    }
  },
  methods: {
    changeDeg: function () {
      setInterval(() => {
        if (this.deg == "0") {
          this.deg = "5";
        } else {
          this.deg = "0";
        }
      }, 500);
    },
    getData(){
      let that = this;
      console.log(this.actId)
      superSaleMould({sign:this.actId})
        .then(res => {
          that.pageDate = res.data;
          that.imageList = that.pageDate.banner.map(item =>{
            return item.img
          })
          console.log(that.imageList);
        //   this.$nextTick(function(){
        //     let swiper = new Swiper("#swiper1", {
        //       slidesPerView: "auto",
        //       spaceBetween: 20,
        //       watchSlidesProgress: true,
        //       // watchSlidesVisibility: true,
        //       observer: true, //修改swiper自己或子元素时，自动初始化swiper
        //       observeParents: true //修改swiper的父元素时，自动初始化swiper
        //     });
        //   })
        })
        .catch(res => {
          that.$dialog.error(res.msg);
        });
      
    },
    toDetail: function (id) {
      if (this.from1 == "app") {
        this.$router.push({
          path: "/detail/" + id + "?mer_id=5070770&from1=" + this.from1,
        });
      } else {
        this.$router.push({
          path: "/detail/" + id + "?mer_id=5070770",
        });
      }
    },
    toListPage: function () {
      if (this.from1 == "app") {
        this.$router.push({
          path: "/goods_list/5070770?from1=" + this.from1 + "&isshowTui=1",
        });
      } else {
        this.$router.push({
          path: "/goods_list/5070770?isshowTui=1",
        });
      }
    },
    toSalePage: function () {
      if (this.from1 == "app") {
        this.$router.push({
          path: "/goods_list/5058293?from1=" + this.from1,
        });
      } else {
        this.$router.push({
          path: "/goods_list/5058293",
        });
      }
    },

    getTitle: function () {
      var self = this;
      var u = navigator.userAgent,
        app = navigator.appVersion;
      var isAndroid = u.indexOf("Android") > -1 || u.indexOf("Linux") > -1; //g
      var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
      var obj = {
        action: "setTitle",
        content: {
          title: "湛江广播年货节",
        },
      };
      if (isAndroid) {
        App.onAppResponse(JSON.stringify(obj));
      }
    },
  },
};
</script>
<style>
.header .product-bg{
  height: 100%;
}
</style>
<style scoped lang="scss">
.SinglesPage {
  width: 100%;
  min-height: 100vh;
  height: auto;
  background: rgba(146, 2, 1, 1);
  overflow: hidden;
}
.SinglesPage .header {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 4.22rem;
  margin-bottom: 0.18rem;
  overflow: hidden;
}
.SinglesPage .header img {
  display: block;
  width: 100%;
  height: 100%;
}
.father {
  box-sizing: border-box;
  /* background-image: linear-gradient(180deg, rgba(255, 226, 191, 1), rgba(255, 229, 160, 0.16)); */
  border-radius: 0.08rem;
  /* padding: 0.03rem 0; */
  margin-bottom: 0.3rem;
  position: relative;
  z-index: 2;
  /* margin: 0 0.12rem; */
}
.goodsLists {
    width: 7.22rem;
    margin: 0 0.14rem;
    padding: 0.14rem;
    background: rgba(255, 78, 81, 1);
    display: flex;
    border-radius: .1rem;
    justify-content: space-between;
    flex-wrap: wrap;
    .good {
      width: 3.42rem;
      height: 4.92rem;
      background: #ffffff;
      border-radius: 0.08rem;
      overflow: hidden;
      margin-bottom: 0.14rem;
      position: relative;
      .goodPic {
        display: block;
        width: 3.1rem;
        height: 3.08rem;
        margin: 0.18rem 0.16rem 0.1rem 0.16rem;
      }
      .noGood{
          top: 0;
          left: 0;
          position: absolute;
          width: 3.1rem;
          height: 3.08rem;
          // opacity: 0.6;
          margin: 0.18rem 0.16rem 0.1rem 0.16rem;
          background: rgba(255,255,255,0.6);
          .wordAlert{
            margin: 0 auto;
            width: 1.42rem;
            height: auto;
            background: rgba(0, 0, 0, 0.5);
            border-radius: 0.28rem;
            text-align: center;
            font-size: 0.24rem;
            font-weight: 400;
            color: #FFFFFF;
            line-height: 1;
            margin-top: 1.46rem;
            padding: 0.14rem 0;
          }
        }
      .goodDetail {
        width: 100%;
        padding: 0 0.12rem;
        .title {
          margin-top: 0.18rem;
          width: 100%;
          height: 0.26rem;
          font-size: 0.26rem;
          font-weight: 400;
          color: #000000;
          line-height: 0.28rem;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
        .shareAndget {
          display: flex;
          justify-content: space-between;
          padding-top: 0.12rem;
          .get {
            min-width: 1.58rem;
            width: auto;
            height: 0.4rem;
            background: #ff4e51;
            border-radius: 0.04rem;
            display: flex;
            justify-content: start;
            align-items: center;
            overflow: hidden;
            .word {
              // padding-left: 0.02rem;
              line-height: 1;
              padding-top: 0.045rem;
              width: 0.72rem;
              font-size: 0.22rem;
              display: inline-block;
              transform: scale(0.9);
              -ms-transform:scale(0.9); 	/* IE 9 */
              -moz-transform:scale(0.9); 	/* Firefox */
              -webkit-transform:scale(0.9); /* Safari 和 Chrome */
              -o-transform:scale(0.9); 	/* Opera */
              transform-origin: 0 0;
              // padding: 0.06rem;
              margin-left: 0.04rem;
              color: #fff;
            }
            .priceget {
              margin-right: 0.02rem;
              min-width: 0.82rem;
              width: auto;
              height: auto;
              line-height: 1;
              background: #ffffff;
              border-radius: 0.04rem;
              padding-left: 0.04rem;
              padding-right: 0.04rem;
              padding-top: 0.04rem;
              padding-bottom: 0.04rem;
              font-size: 0.28rem;
              color: #ef3a58;
              -webkit-box-sizing: border-box;
              box-sizing: border-box;
              font-weight: 500;
              span {
                height: auto;
                line-height: 1;
                font-size: 0.24rem;
                display: inline-block;
                -webkit-transform: scale(0.916);
                transform: scale(0.916);
                -webkit-transform-origin: 0 0;
                transform-origin: 0 0;
              }
            }
          }
          .share {
            width: 1.09rem;
            height: 0.44rem;
            background: #ff4e51;
            box-shadow: 0px 0px 0px 0px #ce0000;
            border-radius: 0.04rem;
            font-size: 0.24rem;
            display: inline-block;
            transform: scale(0.916);
            transform-origin: 0 0;
            text-align: center;
            color: #ffffff;
            line-height: 1;
            box-sizing: border-box;
            padding-top: 0.1rem;
          }
        }
        .price {
          width: 100%;
          display: flex;
          justify-content: start;
          align-items: baseline;
          font-size: 0.24rem;
          color: #ef3a58;
          .nowPrice {
            font-size: 0.36rem;
            color: #ef3a58;
            font-weight: 500;
            padding: 0 0.08rem 0 0.02rem;
          }
          .oldPrice {
            font-size: 0.24rem;
            font-weight: 400;
            color: #a5a1a1;
            text-decoration: line-through;
          }
        }
      }
    }
  }
.SinglesPage .goodsList {
  width: 7.5rem;
  height: auto;
  /* background: linear-gradient(180deg, #EB3018 0%, rgba(223, 37, 37, 0.93) 100%); */
  border-radius: 0.08rem;
  /* border-radius: 0.08rem;
        border: 0.03rem solid; */
  /* border-image: linear-gradient(180deg, rgba(255, 226, 191, 1), rgba(255, 229, 160, 0.16)) 3 3; */
}
.SinglesPage .goodsList .lookmore {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 0.26rem;
  padding-bottom: 0.26rem;
}
.SinglesPage .goodsList .lookmore p {
  font-size: 0.28rem;
  font-weight: 600;
  color: #ffffff;
  line-height: 0.4rem;
  margin: 0 0.08rem 0 2.92rem;
}
.SinglesPage .goodsList .lookmore img {
  width: 0.2rem;
}
.SinglesPage .dis {
  width: 100%;
  height: 1.12rem;
  margin-bottom: 0.2rem;
}
.SinglesPage .dis img {
  /* margin-top: 0.16rem; */
  width: 100%;
  height: 100%;
  display: block;
}
.SinglesPage .listDivSmall {
  width: 7.5rem;
//   margin: 0 0.1rem 0 0.1rem;
  display: flex;
  box-sizing: border-box;
  display: -webkit-flex;
  justify-content: space-between;
  flex-direction: row;
  flex-wrap: wrap;
  height: auto;
  /* padding-bottom: 0.2rem; */
}
.SinglesPage .listDivSmall img {
  width: 2.38rem;
  height: 3.68rem;
  margin-bottom: 0.08rem;
}
.SinglesPage .listDivBig {
  width: 7.3rem;
  margin: 0 0.1rem 0.04rem 0.1rem;
  display: flex;
  display: -webkit-flex;
  justify-content: space-between;
  flex-direction: row;
  flex-wrap: wrap;
  height: auto;
}
.SinglesPage .listDivBig img {
  width: 3.6rem;
  height: 5.14rem;
  margin-bottom: 0.08rem;
}
.SinglesPage .bottomDiv1 {
  bottom: 0;
  position: fixed;
  z-index: 3;
  width: 100%;
  height: 1.36rem;
  background: #9c0000;
}
.SinglesPage .bottomDiv1 .bottomDiv {
  width: 100%;
  height: 1.36rem;
  display: flex;
  justify-content: flex-start;
}
.SinglesPage .bottomDiv .bg {
  height: 0.84rem;
  display: flex;
  justify-content: flex-start;
  width: 6.48rem;
  margin: 0.24rem 0.5rem 0.24rem 0.51rem;
  background: linear-gradient(180deg, #ffdfb8 0%, #ffb53c 100%);
  border-radius: 0.44rem;
}
.SinglesPage .bottomDiv p {
  font-size: 0.4rem;
  font-weight: 500;
  color: rgba(118, 50, 5, 1);
  line-height: 0.56rem;
  margin: 0.16rem 0.1rem 0.16rem 1.02rem;
  font-weight: 600;
}
.SinglesPage .bottomDiv .go {
  width: 0.8rem;
  height: 0.74rem;
  margin-right: 0.1rem;
  margin-top: 0.08rem;
}
.SinglesPage .bottomDiv .jian {
  width: 0.32rem;
  height: 0.32rem;
  margin-right: 0.86rem;
  margin-top: 0.28rem;
}
</style>
